package nl.scalasim

import scala.actors.Actor

/** Producer actor. */
class Producer(name: String, val goods: String) extends ScalasimActor(name) {
  
  def act {
    loop {
      react (handleProduce orElse handleDefault)
    }
  }

  /** Handler for Produce messages. */
  def handleProduce(): PartialFunction[Any, Unit] = {
    case Produce => {
      val amount = 1
      info("Producing %d %s", amount, goods)
      reply(Produced(goods, amount))
    }
  }
}

